package de.xt.logging.utils;

import java.io.File;

public class ProcessCheck extends Thread {

	public final boolean isWindows;
	public final File file;
	public final String backupPath;
	public final boolean backup;
	public final String formating;
	public final String pathToStorage;
	public final String prefix;
	public final boolean ooc;
	public final boolean farbcode;
	public final boolean loginNachrichten;
	public final boolean party;
	public final boolean pns;
	public final boolean shouts;

	public ProcessCheck(final boolean isOnWindows, final File aFile, final boolean doBackups, final String formating, final String pathToStorage, 
			final String prefix, final boolean ooc, final boolean farbcode, final boolean loginNachrichten, final boolean party, final boolean pns, final boolean shouts, final String backupPath){
			this.isWindows = isOnWindows;
			this.file = aFile;
			this.backup = doBackups;
			this.formating = formating;
			this.pathToStorage = pathToStorage;
			this.prefix = prefix;
			this.ooc = ooc;
			this.farbcode = farbcode;
			this.loginNachrichten = loginNachrichten;
			this.party = party;
			this.pns = pns;
			this.shouts = shouts;
			this.backupPath = backupPath;
	}
	
	@Override
	public void run() {
		boolean isRunning = false;
		boolean hadRun = false;
		do {

			if(!isRunning && !hadRun) {
				isRunning = VBSUtils.isRunning(isWindows);
			}

			if(!hadRun){
				hadRun = VBSUtils.isRunning(isWindows);
			}
			
			if (!VBSUtils.isRunning(isWindows) && hadRun) {
				CopyTask.copyLog(file, backup, backupPath, formating,
						pathToStorage, prefix, ooc, farbcode, loginNachrichten,
						party, pns, shouts);
				isRunning = false;
				hadRun = false;
			}
			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
			}
		} while (true);
	}

}
